package com.woniuxy.service.impl;

import com.woniuxy.dao.RbacManagerPermDao;
import com.woniuxy.entity.RbacManagerPerm;
import com.woniuxy.service.RbacManagerPermService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * (RbacManagerPerm)表服务实现类
 *
 * @author makejava
 * @since 2021-04-25 23:04:54
 */
@Service("rbacManagerPermService")
public class RbacManagerPermServiceImpl implements RbacManagerPermService {
    @Resource
    private RbacManagerPermDao rbacManagerPermDao;

    /**
     * 通过ID查询单条数据
     *
     * @param managerId 主键
     * @return 实例对象
     */
    @Override
    public RbacManagerPerm queryById(Integer managerId) {
        return this.rbacManagerPermDao.queryById(managerId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<RbacManagerPerm> queryAllByLimit(int offset, int limit) {
        return this.rbacManagerPermDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param rbacManagerPerm 实例对象
     * @return 实例对象
     */
    @Override
    public RbacManagerPerm insert(RbacManagerPerm rbacManagerPerm) {
        this.rbacManagerPermDao.insert(rbacManagerPerm);
        return rbacManagerPerm;
    }

    /**
     * 修改数据
     *
     * @param rbacManagerPerm 实例对象
     * @return 实例对象
     */
    @Override
    public RbacManagerPerm update(RbacManagerPerm rbacManagerPerm) {
        this.rbacManagerPermDao.update(rbacManagerPerm);
        return this.queryById(rbacManagerPerm.getManagerId());
    }

    /**
     * 通过主键删除数据
     *
     * @param managerId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer managerId) {
        return this.rbacManagerPermDao.deleteById(managerId) > 0;
    }
}
